package cn.tedu.jbdc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection()){
            Statement statement = connection.createStatement();
            String sql = "select username,password,age from userinfo";

            ResultSet r = statement.executeQuery(sql);
            while (r.next()){
                String username = r.getString("username");
                String password = r.getString("password");
                int age = r.getInt("age");

                System.out.println("username:"+username+"  password:"+password+"  age:"+age);

            }


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }
}
